using BW.WMS.Application.Features.Supperss.Dtos;
using BW.WMS.Application.Features.Supperss.Interfice;
using BW.WMS.Core.Result;
using Microsoft.AspNetCore.Mvc;

namespace BW.WMS.API.Controllers
{
    /// <summary>
    /// 供应商商品分配控制器
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class SupplierProductController : ControllerBase
    {
        private readonly ISupperServices _supperServices;

        public SupplierProductController(ISupperServices supperServices)
        {
            _supperServices = supperServices;
        }
        /// <summary>
        /// 为供应商分配商品
        /// </summary>
        /// <param name="assignmentDto">分配信息</param>
        /// <returns>操作结果</returns>
        [HttpPost]
        public ApiResult<int> AssignProductToSupplier([FromBody] SupplierProductAssignmentDto assignmentDto)
        {
            return _supperServices.AssignProductToSupplier(assignmentDto);
        }
        /// <summary>
        /// 移除供应商商品分配
        /// </summary>
        /// <param name="id">分配记录ID</param>
        /// <returns>操作结果</returns>
        [HttpDelete]
        public ApiResult<bool> RemoveProductFromSupplier(int id)
        {
            return _supperServices.RemoveProductFromSupplier(id);
        }

        /// <summary>
        /// 获取供应商已分配的商品列表
        /// </summary>
        /// <param name="queryDto">查询条件</param>
        /// <returns>分页结果</returns>
        [HttpGet]
        public ApiPage<SupplierProductInfoDto> GetSupplierProducts([FromQuery] SupplierProductQueryDto queryDto)
        {
            return _supperServices.GetSupplierProducts(queryDto);
        }

        /// <summary>
        /// 获取可分配给供应商的商品列表
        /// </summary>
        /// <param name="supplierId">供应商ID</param>
        /// <returns>可分配商品列表</returns>
        [HttpGet]
        public ApiResult<List<AvailableProductDto>> GetAvailableProducts(int supplierId)
        {
            return _supperServices.GetAvailableProducts(supplierId);
        }

        /// <summary>
        /// 更新供应商商品分配信息
        /// </summary>
        /// <param name="assignmentDto">分配信息</param>
        /// <returns>操作结果</returns>
        [HttpPut]
        public ApiResult<bool> UpdateSupplierProduct([FromBody] SupplierProductAssignmentDto assignmentDto)
        {
            return _supperServices.UpdateSupplierProduct(assignmentDto);
        }

      
    }
} 